#!/bin/bash

log=$1
cmd=$2
donefile=$3
${cmd}> $log &

# timely check if this job is finished
while : ;
do
sleep 3
status=`jobs|grep "Running"`
if [ "${status}" = "" ];
then
echo "${log}" >> ${donefile}
exit
fi
# echo "DEBUG: next loop `jobs`"
done